<?php
class NewsPageForm extends Form
{
	function __construct()
	{				
		Form::Form('NewsPageForm');
		
		$news_title		= 'Tin tức';

		$str_keywords 	= '';
		$str_catSub 	= '';		
		$meta_keywords 	= '';
		$meta_desc 		= '';

	}
	
	function draw()
	{
		global $display;
		
		$cat_newss = array();
		
		$display->add('is_admin',User::have_permit(ADMIN_NEWS));
		
		$display->add('url_home',WEB_DIR);
		$display->add('time_now',News::displayTime());
		
		$display->add('cat_name',$this->news_cat['name']);
		$display->add('cat_url',URL::build('news_list',array('news_catid'=>$this->news_cat['id'],'azname'=>AZLib::safe_title($this->news_cat['name']))));
		
		
		$condition=' status=1 ';
		
		$total = DB::count("news",$condition);
		
		$limit='';
		
		//$pagging	= AZPagging::paging_list($limit,20,'page_no');
		$pagging	= AZPagging::paging_list($limit,$total,20);
		
		$re	= DB::query('SELECT * FROM news WHERE '.$condition.' ORDER BY id DESC'.$limit);
		
		if($re)
		{	
			while ($news = mysql_fetch_assoc($re))
			{	
				$news['title'] 	= stripslashes($news['title']);
				$news['brief'] 	= stripslashes($news['brief']);
				
				$news['url'] 	= Url::build('news_detail',array('news_catid'=>$news['news_catid'],'news_id'=>$news['id'],'azname'=>AZLib::safe_title($news['title'])));
				
				if($news['image'])
				{
					$news['image'] = AZLib::getImageThumb($news['image'],150,0,0,$news['img_server']);
				}
				
				$news['news_h'] = date('H:i',$news['time_created']);
				$news['news_d'] = date('d-m-Y',$news['time_created']);
						
				$news['admin_link'] = News::admin_link($news);
				
				$cat_newss[$news['id']] = $news;
			}
		}
		
		
		$display->add('pagging',$pagging);
		
		
		$display->add('cat_newss',$cat_newss);
		
		$display->output("NewsPage");
	}
}
?>